﻿using BPMN.appilcation.IService;
using BPMN.Domid.IReposict;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BPMN.appilcation.Service
{
    public class ServiceBase<T>: IServiceBase<T> where T : class
    {
        private readonly IReposictBase<T> repository;

        public ServiceBase(IReposictBase<T> repository)
        {
            this.repository = repository;
        }

        public Task<int> Add(T entity)
        {
           return repository.Add(entity);   
        }

        public Task<int> Delete(int id)
        {
           return repository.Delete(id);
        }

        public Task<T> Get(int id)
        {
           return repository.Get(id);
        }

        public Task<IQueryable<T>> GetAll()
        {
            return repository.GetAll();
        }

        public Task<dynamic> GetListByPage(int pageIndex = 1, int pageSize = 2)
        {
           return repository.GetListByPage(pageIndex, pageSize);
        }

        public Task<int> SaveChange()
        {
            return repository.SaveChange();
        }

        public Task<int> Update(T entity)
        {
           return repository.Update(entity);
        }
    }
}
